//
// Created by root on 10/17/22.
//

#ifndef KIRAN_FLAMESHOT_FREEHANDSNAPGRAPHICSSCENE_H
#define KIRAN_FLAMESHOT_FREEHANDSNAPGRAPHICSSCENE_H


#include <QGraphicsView>

class FreeHandSnapGraphicsScene : public QGraphicsScene
{
Q_OBJECT
public:
    FreeHandSnapGraphicsScene(QWidget *parent = nullptr);

    ~FreeHandSnapGraphicsScene();

    QPolygonF getPathPolygonF();

    QRectF getPathRect();

    bool isHasNewUnsurePath() const;

protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
    void refreshPathItem(QPainterPath path);
    void refreshGrayArea();

private:
    bool mousePressed;

    QPainterPath* unsurePath;
    bool hasNewUnsurePath;
    QPainterPath* path;
    QGraphicsItem* pathItem;
    QGraphicsItem* grayItem;
    QColor grayColor;
};


#endif //KIRAN_FLAMESHOT_FREEHANDSNAPGRAPHICSSCENE_H
